package com.lt.test.consumer.web.controller;//package com.lt.test.consumer.controller;
//
//import com.lt.test.api.LeaveService;
//import com.lt.test.common.util.WebUtils;
//import com.lt.test.entity.DTO.ActiveUser;
//import com.lt.test.entity.DTO.ResponseDTO;
//import net.sf.json.JSONObject;
//import org.activiti.engine.runtime.ProcessInstance;
//import org.activiti.engine.task.Task;
//import org.apache.shiro.SecurityUtils;
//import org.apache.shiro.session.Session;
//import org.apache.shiro.subject.Subject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//import java.util.Map;
//
///**
// * @author lt
// * @date 2018/11/20 15:11
// */
//@Controller
//@RequestMapping("/leave")
//public class LeaveController {
//
//    @Reference(version = "1.0.0")
//    private LeaveService leaveService;
//
//    /**
//     * 页面跳转
//     * @return
//     */
//    @RequestMapping("/leaveManage")
//    public String leaveManage(){
//        return "content/process/leaveManage";
//    }
//    @RequestMapping("/audit_bz")
//    public String audit_bz(){
//        return "content/process/audit_bz";
//    }
//    @RequestMapping("/task")
//    public String task(){
//        return "content/process/task";
//    }
//    @RequestMapping("/daibanManage")
//    public String daibanManage(){
//        return "content/process/daibanManage";
//    }
//    /**
//     * 分页查询业务
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping("/leaveList")
//    public @ResponseBody ResponseDTO
//    leavePage(HttpServletRequest request) {
//        Map<String,Object> parameter = WebUtils.getAllParamMap(request);
//        ResponseDTO responseDTO = new ResponseDTO();
//        //shiro管理的session
//        Subject subject = SecurityUtils.getSubject();
//        ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
//        String userId = activeUser.getUserId();
//        parameter.put("userId", userId);
////		int leaveCount = leaveService.leaveCount(map);
//        try {
//            List<Map<String, Object>> leaveList = leaveService.findForList(parameter);
//            responseDTO.setData(leaveList);
//            responseDTO.setCode("000");
//            responseDTO.setSuccess(true);
//            responseDTO.setMessage("获取成功");
//        } catch (Exception e) {
//            responseDTO.setCode("500");
//            responseDTO.setSuccess(false);
//            responseDTO.setMessage("获取错误");
//        }
////        mv.addObject("leaveList", leaveList);
////        mv.setViewName("process/leaveManage");
////
//        return responseDTO;
//    }
//
//    /**
//     * 添加任务流程
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping("/save")
//    public @ResponseBody ResponseDTO save(HttpServletResponse response, HttpServletRequest request) {
//        Map<String,String> parameter = WebUtils.getAllParamMap(request);
//        ResponseDTO responseDTO = new ResponseDTO();
//
//        String success = "添加失败！";
//
//        //shiro管理的session
//        Subject subject = SecurityUtils.getSubject();
//        ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
//        String userId = activeUser.getUserId();
//        parameter.put("userId", userId);
//
////        parameter.put("userId", userId);
//        //添加用户对象
//        try {
//            leaveService.save(parameter);
//            responseDTO.setCode("000");
//            responseDTO.setSuccess(true);
//            responseDTO.setMessage("操作成功");
//        } catch (Exception e) {
//            responseDTO.setCode("500");
//            responseDTO.setSuccess(false);
//            responseDTO.setMessage("操作失败");
//        }
//        return responseDTO;
//    }
//
//    /**
//     * 提交流程申請
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping("/startApply")
//    public @ResponseBody ResponseDTO startApply(HttpServletResponse response, HttpServletRequest request){
//        Map<String,Object> parameter = WebUtils.getAllParamMap(request);
//        //shiro管理的session
//        Subject subject = SecurityUtils.getSubject();
//        ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
//        String userId = activeUser.getUserId();
//        parameter.put("userId", userId);
//        ResponseDTO responseDTO = new ResponseDTO();
//        try {
//            leaveService.updateLeave(parameter);
//            responseDTO.setCode("000");
//            responseDTO.setSuccess(true);
//            responseDTO.setMessage("操作成功");
//        } catch (Exception e) {
//            responseDTO.setCode("500");
//            responseDTO.setSuccess(false);
//            responseDTO.setMessage("操作失败");
//        }
//        return responseDTO;
//    }
//
//    /**
//     * 查询流程信息
//     * @param taskId  流程实例ID
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping("/getLeaveByTaskId")
//    public @ResponseBody ResponseDTO getLeaveByTaskId(HttpServletResponse response, HttpServletRequest request) {
//        Map<String,Object> parameter = WebUtils.getAllParamMap(request);
//        //shiro管理的session
//        Subject subject = SecurityUtils.getSubject();
//        ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
//        String userId = activeUser.getUserId();
//        parameter.put("userId", userId);
//        ResponseDTO responseDTO = new ResponseDTO();
//        try {
//            List<Map<String, Object>> list = leaveService.getLeaveByTaskId(parameter);
//            responseDTO.setData(list);
//            responseDTO.setCode("000");
//            responseDTO.setSuccess(true);
//            responseDTO.setMessage("获取成功");
//        } catch (Exception e) {
//            responseDTO.setCode("500");
//            responseDTO.setSuccess(false);
//            responseDTO.setMessage("操作失败");
//        }
//        return responseDTO;
//    }
//
//    /**
//     * 通过个人
//     * 查询当前的任务
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping("/findMyPersonalTask")
//    public @ResponseBody ResponseDTO findMyPersonalTask(HttpServletResponse response, HttpServletRequest request) {
//        Map<String,Object> parameter = WebUtils.getAllParamMap(request);
//        //shiro管理的session
//        Subject subject = SecurityUtils.getSubject();
//        ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
//        String userId = activeUser.getUserId();
//        parameter.put("userId", userId);
//        ResponseDTO responseDTO = new ResponseDTO();
//        try {
//            List<Map<String, Object>> list = leaveService.findMyPersonalTask(parameter);
//            responseDTO.setData(list);
//            responseDTO.setCode("000");
//            responseDTO.setSuccess(true);
//            responseDTO.setMessage("获取成功");
//        } catch (Exception e) {
//            responseDTO.setCode("500");
//            responseDTO.setSuccess(false);
//            responseDTO.setMessage("操作失败");
//        }
//        return responseDTO;
//    }
//
//    /**
//     * 待办流程查询
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping("/taskList")
//    public @ResponseBody ResponseDTO taskList(HttpServletResponse response, HttpServletRequest request) {
//        Map<String,Object> parameter = WebUtils.getAllParamMap(request);
//        //shiro管理的session
//        Subject subject = SecurityUtils.getSubject();
//        ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
//        String roleId = activeUser.getRoleId();
//        parameter.put("roleId", roleId);
//        ResponseDTO responseDTO = new ResponseDTO();
//        try {
//            List<Map<String, Object>> list = leaveService.taskList(parameter);
//            responseDTO.setData(list);
//            responseDTO.setCode("000");
//            responseDTO.setSuccess(true);
//            responseDTO.setMessage("获取成功");
//        } catch (Exception e) {
//            responseDTO.setCode("500");
//            responseDTO.setSuccess(false);
//            responseDTO.setMessage("操作失败");
//        }
//        return responseDTO;
//    }
//}
